<?php

namespace App\Admin\Controllers\ChatManage;

use App\Http\Controllers\Controller;

use App\Models\ChatRoomUser;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Row;
use Illuminate\Http\Request;
use Encore\Admin\Widgets\Table;
use Encore\Admin\Controllers\ModelForm;

class ChatRoomUserController
{
    use ModelForm;

    public function index()
    {
        return Admin::content(function(Content $content){
            $content->header( '聊天室用户管理');
            $content->body($this->grid()->render());

        });
    }
    public function edit($id) {
        return Admin::content(function (Content $content) use ($id) {
            $content->body($this->form()->edit($id));
        });
    }

    protected function grid(){
        return Admin::grid(ChatRoomUser::class,function(Grid $grid){
            $grid->id('编号')->sortable();
            $grid->platform_name('平台名称');
            $grid->enable('状态')->display(function ($enable){
                return $enable==0?'关闭':'活动中';
            });
            $grid->room_name('聊天室名称')->editable();
            $grid->disableExport();
            $grid->disableCreation();

        });
    }

    protected function form()
    {
        return Admin::form(ChatRoomUser::class, function (Form $form) {
            $form->display('id', '编号');
//            $form->text('platform_name','平台名称');
//            $form->switch('enable','状态');
//            $form->text('platform_code', '平台唯一标识码');
//            $form->text('sign_key', '平台签名秘钥');
        });
    }
}
